cmake_minimum_required(VERSION 3.8)
project(test_sophus)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(Sophus REQUIRED)
find_package(Eigen3 REQUIRED)

include_directories(SYSTEM ${EIGEN3_INCLUDE_DIRS})
add_executable(test_sophus src/test.cpp)
target_include_directories(test_sophus PRIVATE
  ${Sophus_INCLUDE_DIRS}
)
ament_target_dependencies(test_sophus rclcpp Eigen3)
target_link_libraries(test_sophus
  Sophus::Sophus  # 使用命名空间目标
)
# sophus的cmake中对应头文件路径和库文件链接的设置：
# set_target_properties(Sophus::Sophus PROPERTIES
#   INTERFACE_COMPILE_FEATURES "cxx_auto_type;cxx_decltype;cxx_nullptr;cxx_right_angle_brackets;cxx_variadic_macros;cxx_variadic_templates"
#   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
#   INTERFACE_LINK_LIBRARIES "Eigen3::Eigen;fmt::fmt;Ceres::ceres"
# )
#所有需要使用现代CMake目标链接方式target_link_libraries
# 使用现代CMake目标链接方式：
#     用 Sophus::Sophus 替代旧的变量方式
#     这样会自动处理所有包含路径和链接依赖

install(TARGETS test_sophus
  DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
